﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using CommonTestingUtils;
using LightPersist;
using LightPersist.Storage;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestDomainModel;

namespace LightPersistTests
{
	[TestClass]
	public class Context_disposing_should_dispose_storage : FixtureMsTest
	{
		[TestMethod]
		public void Should_dispose_storage()
		{
			var dir = Path.Combine(Path.GetTempPath(),"q");
			var db = LightPersistFactory.Open<XmlStorage, TestDomainModelMetainfo>(dir);

			Throws(() =>
			{
				var x = new XmlStorage();
				x.Connect(dir);
				x.Dispose();
			});

			db.Dispose();

			NotThrows(() =>
			{
				var x = new XmlStorage();
				x.Connect(dir);
				x.Dispose();
			});

		}
	}
}
